package org.tof.hotel.servlet;

import org.apache.log4j.Logger;
import org.tof.hotel.entity.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

public class Registration {
    static Logger logger = Logger.getLogger(Registration.class);

    public void run(HttpServletRequest request, HttpServletResponse response) throws IOException, ClassNotFoundException {
        try {
            request.setCharacterEncoding("UTF-8");
        } catch (UnsupportedEncodingException e) {
            logger.info(e.toString(), e);
        }
    }

    public boolean isEmailFree(String email){
        if (User.findUserByEmail(email) == null){
            return true;
        } else{
            return false;
        }
    }
}
